<template>
  <div v-transition>
    <Title :place="place" :icon="icon" @handleTitleClick="handleTitleClick" :title="title_home"></Title>
    <Map
      ref="gogeMap"
      :positionData="positionData"
      :height="height"
      :lists="list"
      @getGeogInfo="getGeogInfo"
    ></Map>
  </div>
</template>
<script>
import Title from "../layout/Title";
import common from "../common/index";
import { Indicator } from "mint-ui";
import { getAttachmentAgentUrl } from "../Ajax/index";
import Map from "../layout/Map";
export default {
  name: "AgentMap",
  components: {
    Title,
    Map,
    Indicator
  },
  data() {
    return {
      place: "left",
      icon: "fanhui",
      title_home: this.Lang[this.$store.state.lang].map_t1,
      height:
        (document.documentElement.clientHeight || document.body.clientHeight) -
        40 +
        "px",
      list: [],
      positionData: {}
    };
  },
  methods: {
    handleTitleClick() {
      this.$router.go(-1);
    },
    getGeogInfo(data) {
      this.positionData = data;

      Indicator.open({
        text: this.Lang[this.$store.state.lang].map_t6,
        spinnerType: "fading-circle"
      });
      // alert(1)
      let params = common.formdata({
        fuid: this.$store.state.userInfo.fuid,
        timeStamp: new Date().getTime(),
        // obj: this.$store.state.userInfo.fuid,

        flong: data.flong,
        flat: data.flat
      });

      new Promise((resolve, reject) => {
        getAttachmentAgentUrl(params)
          .then(res => {
            this.list = res.data.datas.data;
            Indicator.close();
            resolve();
          })
          .catch(err => {
            reject(err);
          });
      })
        .then(res => {
          this.$refs.gogeMap.initMap();
        })
        .catch(err => {
          Indicator.close();
          common.toast({
            message: this.Lang[this.$store.state.lang][err] || err,
            time: 2000
          });
        });
    }
  },
  mounted() {}
};
</script>
<style  scoped>
</style>